// //启动多进程, 需启用egg-watcher
// require('egg').startCluster({
//     baseDir: __dirname,
//     port: process.env.PORT,
//     workers: 1, // default to cpu count
// });


//启动单进程, egg-watcher已禁用, 修改模块有 egg-core/egg_loader | node-homedir
const egg = require('egg');
const fs = require('fs');
const Application = egg.Application;
const app = new Application({baseDir: __dirname});
const clusterConfig = app.config.cluster || {};
const listenConfig = clusterConfig.listen || {};

let PORT;
if (fs.existsSync('/acs/conf/env.properties')) {
    let con = fs.readFileSync('/acs/conf/env.properties', 'utf8');
    if (con) {
        let res = con.match(/port.NODE_PORT=(.*)/);
        PORT = res[1];
    }
};

PORT = PORT || listenConfig.port || 7001;

require('http').createServer(app.callback()).listen(PORT);

